# 05-统计单词.py

'''

'''
# 1-读取文件 -list -str

# with open('06-test.txt',"r",encoding="utf-8")as file:
#    str = file.read()
#    print(str.count('baidu')) # 6
# 2-统计baidu出现的次数
# 1-读取文件 -list -str
with open('./06-test.txt','r', encoding="utf-8") as file:
    lines = file.readlines()
    words_list = [line.strip().split() for line in lines]
    all_words = [word for sublist in words_list for word in sublist]
    # 2-统计baidu出现的次数
    baidu_count = all_words.count('baidu')
    print(baidu_count)

    